package asimes;

import java.util.Scanner;

/**
 * Created by Liangweiwei on 2016/9/12.
 */
public class Main1 {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int arr[] = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = scanner.nextInt();
        }
        printDistance(arr);
    }

    public static void printDistance(int[] arr){
        int[] distance= new int[arr.length-1];
        for (int i = 0; i < arr.length-1; i++) {
            distance[i] = getDistance(arr[i],arr[i+1]);
        }
        int sum = 0;
        for (int i = 0; i < distance.length; i++) {
            sum += getStepSum(distance,i);
        }
        System.out.println(sum);
    }

    public static int getStepSum(int[] distance,int step){
        int sum =0;
        for (int i = 0; i < distance.length-step; i++) {
            int temp = distance[i];
            for (int j = 0; j < step; j++) {
                temp+=distance[i+j];
            }
            sum+=temp;
        }
        return sum;
    }

    public static int getDistance(int a,int b){
        int sum =0;
        for (int i = a+1; i < b; i++) {
            if (isPrime(i)){
                sum++;
            }
        }
        return sum;
    }

    public static boolean isPrime(int n){
        boolean flag = true;
        if (n<2){
            return false;
        }else {
            for (int i = 2; i < Math.sqrt(n); i++) {
                if (n%i == 0){
                    flag = false;
                    break;
                }
            }
        }
        return flag;
    }

}